package com.dl7.mvp.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;

import com.dl7.mvp.R;
import com.dl7.mvp.local.table.AlbumsListBean;
import com.dl7.mvp.module.manage.albums.AlbumsVideoListActivity;
import com.dl7.mvp.utils.DefIconFactory;
import com.dl7.mvp.utils.ImageLoader;
import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

/**
 * 对应分类下的所有专辑列表
 */
public class AlbumsListAdapter extends BaseQuickAdapter<AlbumsListBean.DataBean.AlbumsBean> {

    public AlbumsListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.adapter_albums_list;
    }

    @Override
    protected void convert(final BaseViewHolder holder, final AlbumsListBean.DataBean.AlbumsBean item) {
        final ImageView ivPhoto = holder.getView(R.id.iv_photo);
        ImageLoader.loadFitCenter(mContext, item.getImageUrl(), ivPhoto, DefIconFactory.provideIcon());
        holder.setText(R.id.tv_title, item.getName());
        holder.setText(R.id.tv_count, "共 " + item.getVideoCount() + " 首.");
        holder.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlbumsVideoListActivity.launch(mContext, item.getId(), item.getName());
            }
        });
    }

}
